package edu.njust.cma.controller;

import edu.njust.cma.DTO.NewProjectRequest;
import edu.njust.cma.pojo.Project;
import edu.njust.cma.pojo.Result;
import edu.njust.cma.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/quality")
public class QualityController {

    /**
     * **质量科**
     *
     * 0.查看所有项目
     * 1.创建检测项目
     * 2.审核材料
     * 3.查看进展
     * 4.导入标准
     */
    @Autowired
    StandardService standardService;
    @Autowired
    QualityService qualityService;
    @Autowired
    ProjectService projectService;
    @Autowired
    SmallProjectService smallProjectService;

    @Autowired
    TaskService taskService;

    @PostMapping("/hh")
    public Result printHa(){
        return Result.success("haha");
    }
    /**
     * 创建项目
     * */
    @PostMapping("/create")
    public Result createProject(@RequestBody NewProjectRequest newProjectRequest) {

        Project project = new Project();

        project.setName(newProjectRequest.getName());
        project.setQualityDirectorId(newProjectRequest.getQualityDirectorId());
        project.setLabDirectorId(newProjectRequest.getLabDirectorId());
        project.setExperimentEvidence(newProjectRequest.getExperimentEvidence());

        qualityService.createProject(project,newProjectRequest.getProjectStanderIds() ,newProjectRequest.getQualityDirectorId());
        return Result.success();
    }

}
